package com.cdp.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cdp.common.core.domain.AjaxResult;
import com.cdp.common.core.domain.entity.SysStoneGrain;
import com.cdp.common.core.domain.entity.SysStoneSize;
import com.cdp.system.dto.StoneGrainDTO;
import com.cdp.system.mapper.SysStoneSizeMapper;
import com.cdp.system.service.ISysStoneSizeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysStoneSizeServiceImpl extends ServiceImpl<SysStoneSizeMapper, SysStoneSize> implements ISysStoneSizeService {


    @Autowired
    private SysStoneSizeMapper sysStoneSizeMapper;
    /**
     * 查询颗粒尺寸
     * @return
     */
    @Override
    public List<SysStoneSize> listStoneSize() {
        List<SysStoneSize> list = list();
        return list;
    }

    /**
     * 石颗粒尺寸下拉模糊查询
     * @param stoneGrainDTO
     * @return
     */
    @Override
    public List<SysStoneSize> listMistedStoneSize(StoneGrainDTO stoneGrainDTO) {
        LambdaQueryWrapper<SysStoneSize> wrapper = new LambdaQueryWrapper<>();
        // 如果传入的 name 不为空
        if (stoneGrainDTO.getName() != null && !stoneGrainDTO.getName().isEmpty()) {
            wrapper.like(SysStoneSize::getName, stoneGrainDTO.getName());
        }

        // 执行查询
        return sysStoneSizeMapper.selectList(wrapper);

    }
}
